<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ZDH 多源ETL新增</title>
    <meta name="keywords" content="ZDH 多源ETL新增">
    <meta name="description" content="ZDH 多源ETL新增">

    <link rel="shortcut icon" href="img/favicon.ico">

    <link href="css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>输入数据源配置</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">

                    <form id="etl_task_add_form" name="etl_task_add_form" method="post" class="form-horizontal"
                          action="">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">ETL说明</label>
                            <div class="col-sm-10">
                                <input id="etl_context" name="etl_context" type="text"
                                       placeholder="ETL说明" class="form-control" aria-required="true"> </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">创建时间</label>
                            <div class="col-sm-10">
                                <input id="create_time" name="create_time" type="text" readonly
                                       placeholder="创建时间" class="form-control" aria-required="true"> </span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div id="data_sources_model_div" name="data_sources_model_div">

                        </div>
                        <!-- 输入数据源开始-->

                        <div class="form-group">
                            <label class="col-sm-2 control-label">ETL任务选择</label>
                            <div class="col-sm-10">
                                <select id="etl_ids" name="etl_ids" data-placeholder="选择ETL任务"
                                        multiple class="chosen-select form-control m-b" tabindex="2">
                                    <option value="" mytype="">选择ETL任务</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">ETL逻辑</label>
                            <div class="col-sm-10" id="div_data_sources_filter_input">
                                <textarea id="etl_sql" name="etl_sql" class="form-control" rows="5" placeholder="ETL逻辑,使用sql语法 example select a.* ,b.* from a,b where a.id=b.id"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">删除临时表</label>
                            <div class="col-sm-10">
                                <textarea id="drop_tmp_tables" name="drop_tmp_tables" class="form-control" rows="2" placeholder="删除中间临时表,直接写要删除的表名"></textarea>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <!-- 输入数据源结束-->

                        <!-- 输出数据源开始-->

                        <div class="form-group">
                            <label class="col-sm-2 control-label">输出数据源选择</label>
                            <div class="col-sm-10">
                                <select id="data_sources_choose_output" name="data_sources_choose_output" data-placeholder="选择数据源..."
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="" mytype="">选择数据源...</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">数据源类型</label>
                            <div class="col-sm-10">
                                <input id="data_source_type_output" name="data_source_type_output" type="text" readonly
                                       placeholder="数据源类型" class="form-control" aria-required="true"> </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">常用参数</label>
                            <div class="col-sm-10">
                                <select id="file_type_output" name="file_type_output"
                                        data-placeholder="文件类型"
                                        class="chosen-select form-control m-b" tabindex="2" style="width: 30%">
                                    <option value="" mytype="">文件类型</option>
                                    <option value="csv" mytype="">CSV</option>
                                    <option value="csv" mytype="">TXT文本</option>
                                    <option value="orc" mytype="">ORC</option>
                                    <option value="parquet" mytype="">PARQUET</option>
                                    <option value="excel" mytype="">EXCEL</option>
                                    <option value="json" mytype="">JSON</option>
                                    <option value="xml" mytype="">XML</option>
                                    <option value="hudi" mytype="">HUDI</option>
                                    <option value="delta" mytype="">DELTA</option>
                                </select>
                                <select id="encoding_output" name="encoding_output"
                                        data-placeholder="编码"
                                        class="chosen-select form-control m-b" tabindex="2" style="width: 30%">
                                    <option value="" mytype="">编码</option>
                                    <option value="GBK" mytype="">GBK</option>
                                    <option value="GB2312" mytype="">GB2312</option>
                                    <option value="GB18030" mytype="">GB18030</option>
                                    <option value="UTF-8" mytype="">UTF-8</option>
                                    <option value="ISO-8859-1" mytype="">ISO-8859-1</option>
                                </select>
                                <select id="header_output" name="header_output"
                                        data-placeholder="标题"
                                        class="chosen-select form-control m-b" tabindex="2" style="width: 30%">
                                    <option value="" mytype="">标题</option>
                                    <option value="true" mytype="">有</option>
                                    <option value="false" mytype="">无</option>
                                </select>
                            </div>

                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">分割符</label>
                            <div class="col-sm-10"><input id="sep_output" name="sep_output" type="text"
                                                          placeholder="分割符" class="form-control"></div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">其他参数</label>
                            <div class="col-sm-10" id="div_data_sources_params_output">
                                <textarea id="data_sources_params_output" name="data_sources_params_output" class="form-control" rows="2" placeholder="参数使用固定格式{&#34;k&#34;:&#34;v&#34;,&#34;k1&#34;:&#34;v1&#34;}"></textarea>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <div id="div_data_sources_table_name_output" >
                                <label class="col-sm-2 control-label">输出表名</label>
                                <div class="col-sm-10" >

                                    <select id="data_sources_table_name_output" name="data_sources_table_name_output"
                                            data-placeholder="选择数据表..."
                                            class="chosen-select form-control m-b" tabindex="2">
                                        <option value="">选择数据表...</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group"></div>
                            <div id="div_data_sources_file_name_output">
                                <label class="col-sm-2 control-label">输出文件名</label>
                                <div class="col-sm-10" >
                                    <input id="data_sources_file_name_output" name="data_sources_file_name_output" type="text"
                                           placeholder="表名/文件全路径" class="form-control" aria-required="true" onmouseleave="check_tb_name()"> </span>
                                </div>
                            </div>

                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">清空条件</label>
                            <div class="col-sm-10" id="div_data_sources_clear_output">
                                <textarea id="data_sources_clear_output" name="data_sources_clear_output" class="form-control" rows="2" placeholder="清空条件,使用sql语法 example: delete from user where etl_date=2019-12-01,如果是hbase数据源直接输入start_row_key,end_row_key 通过逗号分割 example: 001,100"></textarea>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>

                        <!-- 输出数据源结束-->

                        <div class="form-group">
                            <div class="text-center">
                                <button id="save_etl_task" name="save_zdh" class="btn btn-primary" οnsubmit='return false'
                                        type="button">保存
                                </button>
                                <button id="update_etl_task" name="save_zdh" class="btn btn-primary" οnsubmit='return false'
                                        type="button">更新
                                </button>
                                <button id="reset" class="btn btn-white" type=reset>清空</button>
                            </div>
                        </div>


                    </form>


                </div>
            </div>



        </div>
    </div>
</div>


<div  id="data_sources_params" class="ibox-content" style="display: none;">
    <p>数据源其他参数api</p>
    <ul>
        <li>JDBC:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;空</li>
        <li>HDFS:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    sep:分割符,特殊字符需要转义,example:{"sep":"\\|"},{"sep","="}</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    fileType:文件类型,可选择parquet,orc,csv,json...,example {"fileType":"csv"}</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    partitionBy:分区字段,example {"partitionBy":"ETL_DATE"}</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    model:文件写入模式 默认append,overwrite,append,errorifexists,ignore,example {"model":"overwrite"}</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    encoding:文件编码 默认UTF-8,example {"encoding":"gbk"}</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    merge: 合并小文件 手动填写分区个数example {"merge":"50"}</li>
        <li>HIVE:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format:orc,parquet</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;partitionBy:分区字段</li>
        <li>KAFKA:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msgType:消息类型,支持csv,json 2种格式</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sep:分割符 当消息类型选择csv 时使用</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;groupId:消费者组，默认g1</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kafka的topic 在文件名输入框配置</li>
        <li>HTTP:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;空</li>
        <li>REDIS:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data_type:写入数据类型，可选，string,hash,list,set,table</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key.column:当选择写入数据类型为table 时配置此选项可以生成特定规则key</li>
        <li>CASSANDRA:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;空</li>
        <li>ES:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;空</li>
        <li>SFTP:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fileType:文件类型默认csv,可选csv,orc,parquet,json</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sep:文件分割符,默认逗号分割</li>
        <li>KUDU:</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;primary_key:指定表主键字段,默认会生成一个zdh_auto_md5字段作为主键</li>
        <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;replicas:指定副本个数,默认1个备份</li>
    </ul>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- Bootstrap table -->
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<!-- Chosen -->
<script src="js/plugins/chosen/chosen.jquery.js"></script>

<!-- layer javascript -->
<script src="js/plugins/layer/layer.min.js"></script>

<!-- Toastr script -->
<script src="js/plugins/toastr/toastr.min.js"></script>




<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });


    (function(document, window, $) {


        (function () {
            var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
            var params = url.substr(1);//去掉问号
            var pa = params.split("&");
            var s = new Object();//定义一个全局变量-存储任务ID
            for(var i = 0; i < pa.length; i ++){
                s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
            }

            $('#file_type_output').chosen()
            $('#encoding_output').chosen()
            $('#header_output').chosen()

            //初始化数据源--把所有数据源都加载到下拉框
            function init_data_sources(){
                $.ajax({
                    type: 'POST',
                    url: "etl_task_list",
                    dataType: 'json',
                    async: false,
                    data: '',
                    //成功返回
                    success: function (data) {
                        var str = '<option value=\"\" mytype=\"\" hassubinfo=\"true\"></option>';
                        for (var i = 0; i < data.length; i++) {
                            str += '<option value=\"' + data[i].id + "\" mytype=\"" + data[i].id + "\" hassubinfo=\"true\">" + data[i].etl_context + "</option>"
                        }
                        //ETL单任务下拉框
                        $('#etl_ids').html(str);
                        $('#etl_ids').chosen().on("change", function (evt, params) {
                            $("#etl_ids").trigger("chosen:updated");
                        });

                    },
                    //处理完成
                    complete: function () {
                        console.info("complete")
                    },
                    //报错
                    error: function (data) {
                        console.info("error: " + data.responseText);
                    }
                });

                $.ajax({
                    type: 'POST',
                    url: "data_sources_list",
                    dataType: 'json',
                    async: false,
                    data: '',
                    //成功返回
                    success: function (data) {
                        var str = '<option value=\"\" mytype=\"\" hassubinfo=\"true\"></option>';
                        for (var i = 0; i < data.length; i++) {
                            str += '<option value=\"' + data[i].id + "\" mytype=\"" + data[i].data_source_type + "\" hassubinfo=\"true\">" + data[i].data_source_context + "</option>"
                        }
                        //输出数据源类型下拉框
                        $('#data_sources_choose_output').html(str);

                        $('#data_sources_choose_output').chosen().on("change", function (evt, params) {
                            $('#data_source_type_output').val($('#data_sources_choose_output').find("option:selected").attr("mytype"));
                            $("#data_sources_choose_output").trigger("chosen:updated");
                            if ($('#data_sources_choose_output').find("option:selected").attr("mytype") == 'JDBC') {
                                init_table_name_output($('#data_sources_choose_output').val());

                                $('#div_data_sources_table_name_output')[0].style.display='block';
                                $('#div_data_sources_file_name_output')[0].style.display='block';
                            } else{
                                $('#div_data_sources_file_name_output')[0].style.display='block';
                                $('#div_data_sources_table_name_output')[0].style.display='none';

                            }
                        });

                    },
                    //处理完成
                    complete: function () {
                        console.info("complete")
                    },
                    //报错
                    error: function (data) {
                        console.info("error: " + data.responseText);
                    }
                });
            }


            function init_table_name_output(id) {

                var postData = {
                    id: id,
                }
                $.ajax({
                    type: 'POST',
                    url: "etl_task_tables",
                    dataType: 'json',
                    data: postData,
                    //成功返回
                    success: function (data) {

                        var str = '<option value=\"\" hassubinfo=\"true\"></option>'
                        for (var i = 0; i < data.length; i++) {
                            str += '<option value=\"' + data[i] + '\" hassubinfo=\"true\">' + data[i] + '</option>'
                        }
                        $('#data_sources_table_name_output').html(str);
                        $("#data_sources_table_name_output").trigger("chosen:updated");
                        $('#data_sources_table_name_output').chosen().on("change", function (evt, params) {
                            console.info("'data_sources_table_name_output' event change set text 'data_sources_file_name_output'")
                            $('#data_sources_file_name_output').val($('#data_sources_table_name_output').val())

                        });
                    },
                    //处理完成
                    complete: function () {
                        console.info("complete")
                    },
                    //报错
                    error: function (data) {
                        console.info("error: " + data.responseText);
                    }
                });

            }

            // ------------------------------------------------------------------
            //启动数据源select 初始化函数
            init_data_sources();
            //s.id=-1 表示新增,否则表示更新
            if(s.id==-1){
                console.info("新增按钮触发")
                //$('#data_sources_table_name_input').chosen();
                //$('#data_sources_table_name_output').chosen();
                $('#div_data_sources_table_name_output')[0].style.display = 'none';
                $('#update_etl_task').hide()
                $('#save_etl_task').show()
            }else{
                //init_table_name(s.id)
                if(s.is_copy =="true"){
                    console.info("拷贝按钮触发")
                    $('#update_etl_task').hide()
                    $('#save_etl_task').show()
                }else{
                    console.info("更新按钮触发")
                    $('#save_etl_task').hide()
                    $('#update_etl_task').show()
                }
                buildParam()
            }

            function getMyDate(str){
                var oDate = new Date(str),
                    oYear = oDate.getFullYear(),
                    oMonth = oDate.getMonth()+1,
                    oDay = oDate.getDate(),
                    oHour = oDate.getHours(),
                    oMin = oDate.getMinutes(),
                    oSen = oDate.getSeconds(),
                    oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +" "+getzf(oHour)+":"+getzf(oMin)+":"+getzf(oSen);//最后拼接时间
                return oTime;
            };
            //补0操作
            function getzf(num){
                if(parseInt(num) < 10){
                    num = '0'+num;
                }
                return num;
            }


            function  buildParam(){
                if(s.id !='-1'){
                    console.info("更新按钮触发--开始赋值对应参数:"+s.id)
                    //开始赋值
                    $.ajax({
                        url : "etl_task_more_list",
                        data : "ids=" + s.id,
                        type : "post",
                        async: false,
                        dataType : "json",
                        success : function(data) {
                            console.info("success")


                            //获取输入数据源id
                            var id=data[0].id
                            console.info("参数赋值:多源etl任务id:"+id)

                            //获取ETL 说明
                            var etl_context=data[0].etl_context
                            $("#etl_context").val(etl_context);

                            var create_time=data[0].create_time
                            $("#create_time").val(getMyDate(create_time));

                            //初始化输入数据源select 组件
                            var etl_ids=data[0].etl_ids.split(",")
                            $("#etl_ids").val(etl_ids)
                            $("#etl_ids").trigger("chosen:updated");

                            //获取输入数据源类型
                            var data_source_type_input=data[0].data_source_type_input
                            $("#data_source_type_input").val(data_source_type_input)

                            //获取输入源数据其他参数
                            var etl_sql=data[0].etl_sql
                            $("#etl_sql").val(etl_sql)

                            var drop_tmp_tables=data[0].drop_tmp_tables
                            $("#drop_tmp_tables").val(drop_tmp_tables)


                            // 获取输出数据源
                            var data_sources_choose_output=data[0].data_sources_choose_output
                            //初始化输入数据源select 组件
                            $("#data_sources_choose_output").val(data_sources_choose_output);
                            $("#data_sources_choose_output").trigger("chosen:updated");

                            //获取输出数据源类型
                            var data_source_type_output=data[0].data_source_type_output
                            $("#data_source_type_output").val(data_source_type_output)

                            //输出文件类型参数
                            var file_type_output = data[0].file_type_output
                            $("#file_type_output").val(file_type_output)
                            $("#file_type_output").trigger("chosen:updated");

                            var encoding_output = data[0].encoding_output
                            $("#encoding_output").val(encoding_output)
                            $("#encoding_output").trigger("chosen:updated");

                            var header_output = data[0].header_output
                            $("#header_output").val(header_output)
                            $("#header_output").trigger("chosen:updated");

                            var sep_output = data[0].sep_output
                            $("#sep_output").val(sep_output)

                            //获取输入源数据其他参数
                            var data_sources_params_output=data[0].data_sources_params_output
                            $("#data_sources_params_output").val(data_sources_params_output)

                            //获取输出数据源表名
                            var data_sources_table_name_output=data[0].data_sources_table_name_output;
                            var data_sources_file_name_output=data[0].data_sources_file_name_output

                            if(data_source_type_output=="JDBC"){

                                $('#data_sources_file_name_output').val(data_sources_file_name_output)

                                //初始化数据源对应的表
                                var postData={
                                    id:data_sources_choose_output
                                }

                                $.ajax({
                                    type: 'POST',
                                    url: "etl_task_tables",
                                    dataType: 'json',
                                    data: postData,
                                    //成功返回
                                    success: function (data_table) {

                                        var str = '<option value=\"\" hassubinfo=\"true\"></option>'
                                        for (var i = 0; i < data_table.length; i++) {
                                            str += '<option value=\"' + data_table[i] + '\" hassubinfo=\"true\">' + data_table[i] + '</option>'
                                        }
                                        $('#data_sources_table_name_output').html(str);
                                        $("#data_sources_table_name_output").trigger("chosen:updated");
                                        $('#data_sources_table_name_output').chosen();

                                        //表名再数据源中匹配不到,说明是自己添加的
                                        if(str.search(data_sources_table_name_output) == -1){
                                            check_tb_name()
                                        }
                                        $('#data_sources_table_name_output').val(data_sources_table_name_output);
                                        $("#data_sources_table_name_output").trigger("chosen:updated");
                                    },
                                    //处理完成
                                    complete: function () {
                                        console.info("complete")
                                    },
                                    //报错
                                    error: function (data_table) {
                                        console.info("error: " + data_table.responseText);
                                    }
                                });

                                $('#div_data_sources_table_name_output')[0].style.display='block';
                                $('#div_data_sources_file_name_output')[0].style.display='block';

                            }else{

                                $('#data_sources_file_name_output').val(data_sources_file_name_output)
                                $('#div_data_sources_table_name_output')[0].style.display='none';
                                $('#div_data_sources_file_name_output')[0].style.display='block';
                            }

                            //获取输出删除条件
                            var data_sources_clear_output=data[0].data_sources_clear_output;
                            $('#data_sources_clear_output').val(data_sources_clear_output)



                        },
                        error: function (data) {
                            console.info("error: " + data.responseText);
                        }

                    });

                }
            }

        })();


    })(document, window, jQuery);

    function check_tb_name(){
        if($('#data_source_type_output').val()=="JDBC"){

            if($("#data_sources_table_name_output").html().search('<option value=\"'+$('#data_sources_file_name_output').val()+'\" hassubinfo="true">') == -1){
                var op='<option value=\"'+$('#data_sources_file_name_output').val()+'\" hassubinfo="true">'+$('#data_sources_file_name_output').val()+'</option>'

                $("#data_sources_table_name_output").html($("#data_sources_table_name_output").html()+op)
                $("#data_sources_table_name_output").trigger("chosen:updated");
                $("#data_sources_table_name_output").chosen();
                $("#data_sources_table_name_output").val($('#data_sources_file_name_output').val())
                $("#data_sources_table_name_output").trigger("chosen:updated");
            }
        }
    }

    $('#save_etl_task').click(function () {

        if ($('#etl_context').val() == '') {
            layer.msg("ETL任务说明不能为空！");
            return;
        }

        $.ajax({
            type: 'POST',
            url: "etl_task_more_sources_add",
            dataType: 'json',
            data: $("#etl_task_add_form").serialize(),
            //发送数据前
            beforeSend: function () {
                // 禁用按钮防止重复提交
                $("#save_etl_task").attr({disabled: "disabled"});
            },
            //成功返回
            success: function (data) {
                $("#save_etl_task").removeAttr('disabled');
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            },
            //处理完成
            complete: function () {
                console.info("complete")
            },
            //报错
            error: function (data) {
                $("#save_etl_task").removeAttr('disabled');
                layer.error(data.responseText);
                console.info("error: " + data.responseText);
            }
        });


    })

    $('#update_etl_task').click(function () {

        if ($('#etl_context').val() == '') {
            layer.msg("ETL任务说明不能为空！");
            return;
        }

        var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
        var params = url.substr(1);//去掉问号
        var pa = params.split("&");
        var s = new Object();
        for(var i = 0; i < pa.length; i ++){
            s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
        }

        var tableData=$("#exampleTableEvents").bootstrapTable('getData')

        var column_datas = new Array();// 声明一个数组
        for (var i = 0; i < tableData.length; i++) {
            var column_data={
                column_md5:tableData[i].column_md5,
                column_expr:tableData[i].column_expr,
                column_type:tableData[i].column_type,
                column_alias:tableData[i].column_alias
            }
            column_datas.push(column_data)
        }


        $.ajax({
            type: 'POST',
            url: "etl_task_more_update",
            dataType: 'json',
            data: $("#etl_task_add_form").serialize()+"&"+"id="+s.id,
            //发送数据前
            beforeSend: function () {
                // 禁用按钮防止重复提交
                $("#update_etl_task").attr({disabled: "disabled"});
            },
            //成功返回
            success: function (data) {
                $("#update_etl_task").removeAttr('disabled');
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            },
            //处理完成
            complete: function () {
                console.info("complete")
            },
            //报错
            error: function (data) {
                $("#update_etl_task").removeAttr('disabled');
                layer.error(data.responseText);
                console.info("error: " + data.responseText);
            }
        });

    })

</script>

</body>

</html>
